import Vue from 'vue'
import Router from 'vue-router'
import login from '@/page/login'
import table from '@/page/table'
import my from '@/page/my'
import states from '@/states'

Vue.use(Router)

var router = new Router({
  mode: "history",
  routes: [
    {
      path:'/',
      redirect: '/login'
    },
    {
      mate:{

      },
      path: '/login',
      name: 'login',
      component: login
    },
    /*{
      path: '/my',
      name: 'my',
      component: my
    },*/
    {
      path: '*',
      redirect: '/login'
    }
  ]
});
router.beforeEach((to, form, next) => {
  if (to.name == 'login')
    next();
  else if (states.state.id == null) {
    console.log(states.state.id);
    next("/login");
  } else {
    next();
  }
});
export default router;
